package exercise4;

import java.util.Scanner;




public class Chars extends BaseExample {
//	指定输出ch1和ch2之间的所有字符
	public void printChars(char ch1, char ch2, int numberPerLine) {
		StringBuilder str=new StringBuilder();
		str.append("\n");
		int n = 0;
		for (; ch1 <= ch2; ch1++) {
			str.append(ch1+" ");
			n++;
			if (n == numberPerLine) {
				n = 0;
				str.append("\n");
			}
		}
		this.logger.info(str);
	}

	public void printForchars() {
		this.logger.debug("以每行numberPerLine个字符的方式输出ch1和ch2之间的所有字符");
		String ch1, ch2;
		@SuppressWarnings("resource")
		Scanner s = new Scanner(System.in);
		this.logger.debug("请输入ch1:");
		ch1 = s.next();
		char c1 = ch1.charAt(0);
		this.logger.debug("请输入ַch2:");
		ch2 = s.next();
		char c2 = ch2.charAt(0);
		this.logger.debug("请输入numberPerLine:");
		int num;
		num = s.nextInt();
		printChars(c1, c2, num);
	}
}
